package com.wuyou.designPatterns.factory.abstractfactory.factory;

public abstract class Factory{

    public Factory(){
        System.out.println("Factory的构造方法");
    }
    public static Factory getFactory(Class<? extends Factory> classname){
        Factory factory = null;
        try {
//            factory = (Factory)Class.forName(classname).newInstance();
             factory = classname.newInstance();
//        } catch (ClassNotFoundException e) {
//            System.out.println("类未找到->" + classname);
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
        return factory;
    }

    public abstract Link createLink(String caption, String url);

    public abstract Tray createTray(String caption);

    public abstract Page createPage(String title, String author);
}
